package socketmvc.core.packets;

import socketmvc.core.packets.basic.impl.JsonTextBody;
import socketmvc.core.packets.basic.impl.JsonSimplePacket;

import java.util.HashMap;
import java.util.Map;

public class SocketClosePacket extends JsonSimplePacket {

    private final Map<String,Object> property;

    public SocketClosePacket(){
        this.textBody = new JsonTextBody();
        this.property = new HashMap<>();
        this.textBody.setBody(property);
        this.setCommand("/@socket-close");
    }

    public SocketClosePacket(Integer code,String reason){
        property = new HashMap<>();
        property.put("code",code);
        property.put("reason",reason);
        this.textBody = new JsonTextBody();
        this.textBody.setBody(property);
        this.setCommand("/@socket-close");
    }

    public void putProperty(String key,Object val){
        this.property.put(key,val);
    }
}
